package core

import (
	"gopkg.in/yaml.v3"
	"log"
	"werewolf/config"
	"os"
)

const configFile = "config.yaml"

func LoadYAML() ([]byte, error) {
	return os.ReadFile(configFile)
}

func InitConf() *config.Config {
	c := &config.Config{}
	yamlConf, err := LoadYAML()
	if err != nil {
		log.Fatalf("Failed to load configuration: %v", err)
	}
	if err = yaml.Unmarshal(yamlConf, c); err != nil {
		log.Fatalf("Failed to unmarshal YAML configuration: %v", err)
	}
	return c
}